package edu.neu.swc.skynet.document;

import edu.neu.swc.skynet.movie.MovieShow;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

/**
 * <h1>电影文档类</h1>
 * 与 Elastic Search 中的
 * 数据类型发生映射关系
 */
@NoArgsConstructor
@AllArgsConstructor
@Data
@Document(indexName = "sky_net_movie")
public class MovieDoc {

    /** 电影ID */
    @Id
    private Long id;

    /** 电影名称 */
    @Field(name = "movieName", type = FieldType.Text)
    private String movieName;

    /** 电影海报 */
    @Field(name = "movieImage", type = FieldType.Text)
    private String movieImage;

    /** 电影导演 */
    @Field(name = "movieDirector", type = FieldType.Text)
    private String movieDirector;

    /** 电影主演 */
    @Field(name = "movieMain", type = FieldType.Text)
    private String movieMain;

    /** 电影发布时间 */
    @Field(name = "movieRelease",
            type = FieldType.Text
    )
    private String movieRelease;

    /** 电影生产国家 */
    @Field(name = "movieLocation", type = FieldType.Keyword)
    private String movieLocation;

    /**
     * <h2>MovieDoc -> MovieInfo</h2>
     * @return 转化完成的 MovieInfo
     */
    public MovieShow toMovieShow(){

         MovieShow movieShow = new MovieShow();

         movieShow.setId(this.getId());
         movieShow.setMovieName(this.getMovieName());
         movieShow.setMovieImage(this.getMovieImage());
         movieShow.setMovieDirector(this.getMovieDirector());
         movieShow.setMovieMain(this.getMovieMain());
         movieShow.setMovieRelease(this.getMovieRelease());
         movieShow.setMovieLocation(this.getMovieLocation());

         return movieShow;

    }
}
